package org.example.pdao;



import org.example.puser.xuser;
import org.example.util.DbUtil;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class xdao {
    public List<xuser> querya() {
        List<xuser> li = new ArrayList<xuser>();
        Connection cn = DbUtil.getConn();

        try {
            String select = "select * from student";
            PreparedStatement ps = cn.prepareStatement(select);
            ResultSet rs = ps.executeQuery();
            while (rs.next()) {
                xuser x = new xuser(rs.getInt("id"),
                        rs.getString("品种名称"),
                        rs.getString("链接")
                );
                li.add(x);
            }
        } catch (SQLException e) {
            throw new RuntimeException(e);
        } finally {
            DbUtil.closeConn();
        }
    return li;
    }
}
